<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../common/common.jsp" %>

<!DOCTYPE html>
<html>
<head>
<base href="${contextPath}"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>系统登录</title>
<link href="/resources/assets/BJUI/themes/css/bootstrap.min.css" rel="stylesheet">
<link href="/resources/assets/BJUI/plugins/niceValidator/jquery.validator.css" rel="stylesheet">
<link href="/resources/assets/BJUI/themes/css/FA/css/font-awesome.min.css" rel="stylesheet">
<link href="/resources/assets/plugins/sco/css/sco_message.css" rel="stylesheet" />

<script src="/resources/assets/BJUI/js/jquery-1.7.2.min.js"></script>


<script type="text/javascript">
    
    var fatherPath = window.location.href;
    
    if(fatherPath.indexOf("/admin/index") != -1) {
        window.location.href = "/admin/login";
    }


</script>


<style type="text/css">
* {font-family: "Verdana", "Tahoma", "Lucida Grande", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;}
body {
    background: url('/resources/assets/images/loginbg_01.jpg') no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}
a:link {color: #285e8e;}
.main_box {
    position: absolute; top:50%; left:50%; margin-top:-260px; margin-left: -300px; padding: 30px; width:600px; height:380px;
    background: #FAFAFA; background: rgba(255,255,255,0.5); border: 1px #DDD solid;
    border-radius: 5px;
    -webkit-box-shadow: 1px 5px 8px #888888; -moz-box-shadow: 1px 5px 8px #888888; box-shadow: 1px 5px 8px #888888;
}
.main_box .setting {position: absolute; top: 5px; right: 10px; width: 10px; height: 10px;}
.main_box .setting a {color: #FF6600;}
.main_box .setting a:hover {color: #555;}
.login_logo {margin-bottom: 20px; height: 45px; text-align: center;}
.login_logo img {height: 45px;}
.login_msg {text-align: center; font-size: 16px;}
.login_form {padding-top: 20px; font-size: 16px;}
.login_box .form-control {display: inline-block; *display: inline; zoom: 1; width: auto; font-size: 18px;}
.login_box .form-control.x319 {width: 319px;}
.login_box .form-control.x164 {width: 164px;}
.login_box .form-group {margin-bottom: 20px;}
.login_box .form-group label.t {width: 120px; text-align: right; cursor: pointer;}
.login_box .form-group.space {padding-top: 15px; border-top: 1px #FFF dotted;}
.login_box .form-group img {margin-top: 1px; height: 32px; vertical-align: top;}
.login_box .m {cursor: pointer;}
.bottom {text-align: center; font-size: 12px;}
</style>
<script type="text/javascript">
var COOKIE_NAME = 'sys__username';
$(function() {
    choose_bg();
    
  //验证初始化
    $('#login_form').validator({ 
        theme: 'yellow_right_effect',
        focusCleanup: true,
        stopOnError:true,
        //debug: true,
        timely: 2,
        //自定义规则（PS：建议尽量在全局配置中定义规则，统一管理）
        rules: {
            account: [/^[a-zA-Z0-9]+$/, '用户名无效! 仅支持字母与数字。']
        },
        fields: {
            "account": {
                rule: "required",
                msg: {required: "登陆账号必填!"}
            },
            "password": {
                rule: "required",
                msg: {required: "登陆密码必填!"}
            },
        },
        //验证成功
        valid: function(form) {
            var url = '/webapi/employee/login';
            var $account = $('#account').val();
            var $password = $('#password').val();
            var data = {account:$account, password:$password};
            
            // CH.PostRequest(url, data, success);

            $.ajax({
                type: "post" ,
                url: url ,
                data:JSON.stringify(data),   // JSON.stringify() ： 将对象转换成json字符串。
                contentType : "application/json",
                dataType: "json",
                success: function(result){
                   success(result);
                }   
            });
            
            function success(r) {
                var path = "?";
                path += "employeeId="+r.data.id;
                path += "&employeeName="+r.data.nickname;
                if(r.code == SUCCESS) {
                    top.location='/admin/index'+path;
                } else {
                    CH.common.showError(r.code);
                }
            }
        }
    });

    /*$("#login_form").submit(function(){
        $("#login_ok").attr("disabled", true).val('登陆中..');
        
        var password = HMAC_SHA256_MAC($("#j_username").val(), $("#j_password").val());
        $("#j_password").val(HMAC_SHA256_MAC($("#j_randomKey").val(), password));

        return false;
    });*/
});

function choose_bg() {
    var bg = Math.floor(Math.random() * 9 + 1);
    $('body').css('background-image', 'url(/resources/assets/images/loginbg_0'+ bg +'.jpg)');
}
</script>
</head>
<body>
<div class="main_box">
    <div class="setting"><a href="javascript:;" onclick="choose_bg();" title="更换背景"><span class="glyphicon glyphicon-th-large"></span></a></div>
    <div class="login_box">
        <div class="login_logo">
            <img src="/resources/assets/images/logo.png">
        </div>
        <!-- <div id="result" class="tip-ok" style="display:none">提交成功</div> -->
        <div class="login_form">
            <input type="hidden" value="${randomKey }" id="j_randomKey" />
            <form id="login_form">
                <input type="hidden" name="jfinal_token" value="${jfinal_token }" />
                <div class="form-group">
                    <label for="account" class="t">用户名：</label> <input id="account" value="" name="account" type="text" class="form-control x319 in" autocomplete="off">
                </div>
                <div class="form-group">
                    <label for="password" class="t">密　码：</label> <input id="password" value="" name="password" type="password" class="form-control x319 in">
                </div>
                <div class="form-group space">
                    <label class="t"></label>　　　
                    <input type="submit" id="login_ok" value="&nbsp;登&nbsp;录&nbsp;" class="btn btn-primary btn-lg">&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="reset" value="&nbsp;重&nbsp;置&nbsp;" class="btn btn-default btn-lg">
                </div>
            </form>
        </div>
    </div>
    <div class="bottom">Copyright &copy; 2011 - 2014 <a href="/admin/login">澄泓信息科技有限公司 - 系统登陆</a></div>
</div>

<script src="/resources/assets/BJUI/js/jquery.cookie.js"></script> 
<script src="/resources/assets/js/sha256.js"></script>

<script src="/resources/assets/BJUI/plugins/niceValidator/jquery.validator.js"></script>
<script src="/resources/assets/BJUI/plugins/niceValidator/jquery.validator.themes.js"></script>
<script src="/resources/assets/BJUI/plugins/niceValidator/local/zh_CN.js"></script>

<script src="/resources/assets/js/chenghong/Date.js"></script>
<script src="/resources/assets/js/chenghong/String.js"></script>
<script src="/resources/assets/js/chenghong/statusCode.js"></script>
<script src="/resources/assets/js/chenghong/core.js"></script>
<script src="/resources/assets/js/chenghong/common.js"></script>

<script src="/resources/assets/plugins/sco/js/sco.message.js"></script>

<script src="/resources/assets/BJUI/js/b-jui.all.js"></script>
</body>
</html>